#ifndef QUICKTOOL_H
#define QUICKTOOL_H

#define GLOBAL_QML_STATE_HEAD(type, name)\
Q_PROPERTY(type name READ name WRITE set##name NOTIFY name##Change)

#define GLOBAL_QML_STATE_PROPERTY(type, name , defaultValue) \
Q_PROPERTY(type name READ name WRITE set##name NOTIFY name##Change) \
    private: \
    type m_##name = defaultValue; \
    Q_SIGNALS: \
    void name##Change(const type &value); \
    public: \
    type name() const { \
        return m_##name; \
} \
    void set##name(const type &value) { \
        if (m_##name != value) { \
            m_##name = value; \
            emit name##Change(value); \
    } \
}

#define OR_QML_STATE_PROPERTY(type, name , defaultValue) \
Q_PROPERTY(type name READ name NOTIFY name##Change) \
    Q_SIGNALS: \
    void name##Change(const type &value); \
    private: \
    type m_##name = defaultValue; \
    public: \
    type name() const { \
        return m_##name; \
}\
    void update##name(const type &value) { \
        if (m_##name != value) { \
            m_##name = value; \
            emit name##Change(value); \
    } \
}




#define RW_STATE_PROPERTY(type, name, defaultValue) \
public: \
    type name() const { \
        return m_##name; \
} \
    void set##name(const type &value) { \
        m_##name = value; \
} \
    private: \
    type m_##name = defaultValue;

#endif // QUICKTOOL_H
